Avoid a race between Xend removing the vm entries corresponding to a domain,
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 2 Mar 2006 00:59:28 +0000 (01:59 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 2 Mar 2006 00:59:28 +0000 (01:59 +0100)
and the hotplug scripts checking whether that domain is still alive.  This
triggers the "xenstore-read: couldn't read path /local/domain/107/vm" message
in /var/log/xen-hotplug.log, followed by "Device XYZ is mounted in a guest
domain and so cannot be mounted now".

Closes bug #514.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/examples/block

index b6a374c3c4a8f9cb1c897aa79b7509d96d189e8f..e73ab9c8bfbb37f985bbe4ee5bc3f3dfd3ac8631 100644 (file)
@@ -129,7 +129,14 @@ check_sharing()
 same_vm()
 {
   local otherdom="$1"
-  local othervm=$(xenstore-read "/local/domain/$otherdom/vm")
+  # Note that othervm can be MISSING here, because Xend will be racing with
+  # the hotplug scripts -- the entries in /local/domain can be removed by
+  # Xend before the hotplug scripts have removed the entry in
+  # /local/domain/0/backend/.  In this case, we want to pretend that the
+  # VM is the same as FRONTEND_UUID, because that way the 'sharing' will be
+  # allowed.
+  local othervm=$(xenstore_read_default "/local/domain/$otherdom/vm"         \
+                  "$FRONTEND_UUID")
 
   [ "$FRONTEND_UUID" == "$othervm" ]
 }